<template>
    <div>
      <h2>门店添加</h2>
  
      <table class="table table-bordered">
        <tbody>
          <tr>
            <td><span style="color: red">*</span>店名</td>
            <td>
              <input type="text" name="form.dname" value="老八的店"/>
            </td>
          </tr>
         
          <tr>
            <td><span style="color: red">*</span>服务范围</td>
            <td>
              <select v-model="form.fanwei">
                <option >请选择</option>
                <option>早餐早点</option>
                <option value="">饮料</option>
              </select>
            </td>
          </tr>
  
          <tr>
            <td>店主</td>
            <td>
              <input type="text" name="form.dianzhu" value="老八" />
            </td>
          </tr>
          <tr>
            <td>联系电话</td>
            <td>
              <input type="text" name="form.phone" value="12345678988" />
            </td>
          </tr>
          <tr>
            <td>门店介绍</td>
            <td>
              <textarea name="form.jieshao" > 无</textarea>
            </td>
          </tr>
         
          <tr>
            <td><span style="color: red">*</span>状态</td>
            <td>
              <input
                type="radio"
                v-model="form.zhuangtai"
                name="zhaungtai"
                checked
              />启用
              <input type="radio" v-model="form.zhuangtai" name="zhaungtai" />禁用
            </td>
          </tr>
  
          <tr>
            <td>图片</td>
            <td>
              <img src="/src/img/【玲纱】2024-08-26 15_17_20.png" style="display: ''; max-width: 100px" />
              <input type="file" style="display: ''" id="file" @change="Tupian" />
            </td>
          </tr>
          <tr>
            <td></td>
            <td>
              <button @click="Ad">修改门店</button>
              <a @click="Add"><span style="color: aliceblue">.</span> </a>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </template>
  
  <script setup lang="ts">
  import axios from "axios";
  import { onMounted, reactive, ref } from "vue";
  import { useRouter } from "vue-router";
  import "bootstrap/dist/css/bootstrap.min.css";
  
  const router = useRouter();
  
  const form = reactive({
    id: "",
    name: "",
    pwd: "",
    dname: "",
    yshijian: "",
    fanwei: "",
    dianzhu: "",
    phone: "",
    jieshao: "",
    dizhi: "",
    zhuangtai: "",
    tupian: "",
    sdata: true,
  });
  const Ad=()=>{
    alert("修改成功");
    router.push("showwen")
  }
  
  const Add=()=>{
      if(!form.dname){
          alert("门店名称不能为空");
          return;
      }
      if(!form.dianzhu){
          alert("店主不能为空");
          return;
      }
         
       
    
  }
  
  
  
  const Tupian=(e:any)=>{
      var formdata=new FormData();
      var file=e.target.files[0];
      formdata.append("file",file);
      axios.post("https://localhost:7140/api/gonggao",formdata).then(res=>{
          form.tupian=res.data;
      })
  }
  
  
  </script>
  
  <style scoped></style>
  